﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using University.Workshop.WinApp.Users;
using University.Workshop.WinApp.Clients;
using University.Workshop.Business;
using University.Workshop.WinApp.Product;
using University.Workshop.WinApp.Sale;
using University.Workshop.Model;
using University.Workshop.WinApp.Arching;

namespace University.Workshop.WinApp.Main
{
    public partial class FormMainView : Form
    {
        UserLogOn user = UserLogOn.Instance;
        Variables flag = Variables.Instance;
        public FormMainView()
        {
            InitializeComponent();
        }

        private void toolStripButtonUser_Click(object sender, EventArgs e)
        {
            FormUserView user = new FormUserView();
            user.ShowDialog();
        }

        private void toolStripButtonClients_Click(object sender, EventArgs e)
        {
            flag.Client = "Not browser";
            FormClientsView client = new FormClientsView();
            client.ShowDialog();

        }

        private void FormMainView_Load(object sender, EventArgs e)
        {
            labelUserName.Text = user.Name + " " + user.Surname1 + " " + user.Surname2;
            labelUserName.Location=new Point((this.Width- labelUserName.Width-15),labelUserName.Location.Y);
            labelDateTimeStart.Text = user.DateTimeEnter.ToString();
            labelDateTimeStart.Location = new Point((this.Width - labelDateTimeStart.Width - 15), labelDateTimeStart.Location.Y);
            labelUserCharge.Text = user.Occupation;
            labelUserCharge.Location = new Point((this.Width - labelUserCharge.Width - 15), labelUserCharge.Location.Y);
            LockWindowsByUsers(user.Occupation);
        }

        private void LockWindowsByUsers(string occupation)
        {
            switch (occupation)
            {
                case "Administracion":
                    toolStripButtonBuy.Enabled = true;
                    toolStripButtonUser.Enabled = true;
                    toolStripButtonSells.Enabled = true;
                    toolStripButtonReports.Enabled = true;
                    toolStripButtonProviders.Enabled = true;
                    toolStripButtonProducts.Enabled = true;
                    toolStripButtonClients.Enabled = true;
                    break;
                case "Cajero":
                    toolStripButtonBuy.Enabled = false;
                    toolStripButtonUser.Enabled = false;
                    toolStripButtonSells.Enabled = true;
                    toolStripButtonReports.Enabled = false;
                    toolStripButtonProviders.Enabled = false;
                    toolStripButtonProducts.Enabled = true;
                    toolStripButtonClients.Enabled = true;
                    break;
                case "Almacen":
                    toolStripButtonBuy.Enabled = true;
                    toolStripButtonUser.Enabled = false;
                    toolStripButtonSells.Enabled = false;
                    toolStripButtonReports.Enabled = false;
                    toolStripButtonProviders.Enabled = true;
                    toolStripButtonProducts.Enabled = true;
                    toolStripButtonClients.Enabled = false;
                    break;
            }
        }

        private void toolStripButtonProducts_Click(object sender, EventArgs e)
        {
            flag.Product = "Not browser";
            FormProductView product = new FormProductView();
            product.ShowDialog();
        }

        private void toolStripButtonProviders_Click(object sender, EventArgs e)
        {
            flag.Provider = "Not browser";
            FormProviderView provider = new FormProviderView();
            provider.ShowDialog();
        }

        private void toolStripQuit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        //private void toolStripButtonBuy_Click(object sender, EventArgs e)
        //{
        //    PurchaseView purchase = new PurchaseView();
        //    purchase.ShowDialog();
        //}
        private void toolStripButtonSells_Click(object sender, EventArgs e)
        {
            FormSaleView.Intance.ShowDialog();
        }

        private void toolStripButtonReports_Click(object sender, EventArgs e)
        {
            Reports reportes = new Reports();
            reportes.ShowDialog();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ArchingView arching = new ArchingView();
            arching.ShowDialog();
        }

        private void toolStripGifts_Click(object sender, EventArgs e)
        {
            FormMainGifts gift = new FormMainGifts();
            gift.ShowDialog();
        }

        private void toolStripButtonBuy_Click(object sender, EventArgs e)
        {
            PurchaseView purchaseView = new PurchaseView();
            purchaseView.ShowDialog();
        }
    }
}
